package Classes.GameViews.ViewPanels
{
	import Classes.GameViews.ViewScenes.VS_Main;
	import Classes.GameViews.ViewScenes.ViewScene;
	import Classes.staticinfo.Language;
	
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.system.ApplicationDomain;
	
	public class VP_errorPanel extends ViewPanel
	{
		private static var _instance:VP_errorPanel;
		private var _interfaceUI:Sprite;
		private var dobj:DisplayObject;
		public function VP_errorPanel()
		{
			init();
		}
		
		private function init():void
		{
			this._interfaceUI=new (ApplicationDomain.currentDomain.getDefinition("UI_error_v") as Class);
			dobj=this.addChild(this._interfaceUI);
			dobj.scaleX		=	.4;
			dobj.scaleY		=	.4;
			this._interfaceUI.x=(VP_Main.instance.stage.stageWidth-dobj.width)/2;
			this._interfaceUI.y=(VP_Main.instance.stage.stageHeight/2) -dobj.height;//-dobj.height/.6);
			this.addEventListener("close",closeHandler);
			this.mouseEnabled=false;
		}
		
		public function setErrorMessage(msg:String):void
		{
			this.interfaceUI["setErrorTxt"](msg)
		}
		
		private function closeHandler(e:Event):void
		{
			this.close(false);
			//			GU_Sound.instance.playCommSound("System_Prompt");
		}
		
		public function enterFrame():void
		{
			this.interfaceUI["addEnterFrameEvent"]();
			this.openAt(VS_Main.instance);
//			this.scaleX		=	this.scaleY		=	1;
//			this.x=(ZombieTown.instance.sysStage.stageWidth-this.width)/4;
//			this.y=(ZombieTown.instance.sysStage.stageHeight-this.height)/4;
			this.updatePosition();
		}
		
		/**
		 * 没有此权限的总提示 
		 */		
		public function noPowerMsg():void
		{
			this.setErrorMessage(Language.noOperatePower);
			this.enterFrame();
		}
		
		public static function get instance():VP_errorPanel
		{
			if(!_instance) _instance=new VP_errorPanel();
			return _instance;
		}
		
		public function get interfaceUI():Sprite
		{
			return _interfaceUI;
		}
		
		override public function updatePosition():void
		{
			this._interfaceUI.x=(VP_Main.instance.stage.stageWidth-dobj.width)/2;
			this._interfaceUI.y=(VP_Main.instance.stage.stageHeight/2) -dobj.height;//-dobj.height/.6);
		}
		
	}
}